/* ==================================================================   
 * Created [2009-4-27 下午11:32:55] by Jon.King 
 * ==================================================================  
 * TSS 
 * ================================================================== 
 * mailTo:jinpujun@hotmail.com
 * Copyright (c) Jon.King, 2009-2012 
 * ================================================================== 
 */

package com.jinhe.tss.component.log;

import java.io.Serializable;
import java.util.Date;

import com.jinhe.tss.core.sso.Environment;
import com.jinhe.tss.core.sso.context.Context;
import com.jinhe.tss.core.util.BeanUtil;

public class LogDto implements Serializable {

	private static final long serialVersionUID = -7487832494735528555L;

	public final static Integer LEVEL_1 = new Integer(1);

	public final static Integer LEVEL_2 = new Integer(2);

	public final static Integer LEVEL_3 = new Integer(3);

	public final static Integer LEVEL_4 = new Integer(4);

	private Long   id;
	private String appCode;       // 应用Code
	private Long   operatorId;    // 操作者ID
	private String operatorName;  // 操作者Name
	private String operatorIP;    // 操作者IP
	private String operationCode; // 操作Code
	private String operateTable;  // 操作的表
	private Date   operateTime = new Date(); // 操作时间
	private String content; // 操作内容
	private Integer level;  // 日志级别

	public LogDto() {

	}

	public LogDto(String appCode, Long operatorId, String operatorName,
			String operatorIP, String operationCode, String operateTable,
			String content, Integer level) {
		this.appCode = appCode;
		this.operatorId = operatorId;
		this.operatorName = operatorName;
		this.operatorIP = operatorIP;
		this.operationCode = operationCode;
		this.operateTable = operateTable;
		this.content = content;
		this.level = level;
	}

	public LogDto(String operationCode, Object entity) {
		this.appCode = Context.getApplicationContext().getCurrentAppCode();
		this.operatorId = Environment.getOperatorId();
		this.operatorName = Environment.getOperatorName();
		this.operatorIP   = Environment.getClientIp();
		this.operationCode = operationCode;
		this.operateTable = entity.getClass().getName();
		this.content = BeanUtil.toXml(entity);
		this.level = LogDto.LEVEL_1;
	}

	public String getAppCode() {
		return appCode;
	}

	public String getContent() {
		return content;
	}

	public Long getId() {
		return id;
	}

	public Integer getLevel() {
		return level;
	}

	public Date getOperateTime() {
		return operateTime;
	}

	public String getOperationCode() {
		return operationCode;
	}

	public Long getOperatorId() {
		return operatorId;
	}

	public String getOperatorIP() {
		return operatorIP;
	}

	public String getOperatorName() {
		return operatorName;
	}

	public String getOperateTable() {
		return operateTable;
	}

	public void setAppCode(String appCode) {
		this.appCode = appCode;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public void setOperateTime(Date operateTime) {
		this.operateTime = operateTime;
	}

	public void setOperationCode(String operationCode) {
		this.operationCode = operationCode;
	}

	public void setOperatorId(Long operatorId) {
		this.operatorId = operatorId;
	}

	public void setOperatorIP(String operatorIP) {
		this.operatorIP = operatorIP;
	}

	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}

	public void setOperateTable(String table) {
		this.operateTable = table;
	}
}
